package com.yanu.trace.t2s.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yanu.trace.t2s.entity.Pork;
import com.yanu.trace.t2s.mapper.PorkMapper;
import com.yanu.trace.t2s.service.PorkService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author whj
 * @since 2021-06-23
 */
@Service
@Transactional
public class PorkServiceImpl extends ServiceImpl<PorkMapper, Pork> implements PorkService {
    @Autowired
    PorkMapper porkMapper;

    @Override
    public IPage<Pork> selectPage(Page<?> page) {
        return porkMapper.selectPageVo(page);//联合pork表和enterprise表 返回所有pork实体带上enterprise信息   并分页返回
    }

    @Override
    public IPage<Pork> selectPageByeid(Page<?> page, Integer eid,Integer level) {
        return  porkMapper.selectPageVoByeid(page,eid,level);//根据企业id查询该企业所有猪肉信息 并分页返回
    }

    @Override
    public Pork selectByidPaE(Integer id) {
        return porkMapper.selectByidPaE(id);//根据猪肉id查询该块猪肉的信息和对应的企业信息
    }

    @Override
    public IPage<Pork> selectPageBylevel(Page<?> page, Integer level) {
        return porkMapper.selectPageVoBylevel(page,level);//根据猪肉等级进行分页查询
    }
}
